#!/bin/bash
set -ex

go build -o dkv src/cmd/dkv/dkv.go



trap 'killall dkv' SIGINT

cd $(dirname $0)

killall dkv || true
sleep 0.1


./dkv -db-location=moscow.db -http-addr=127.0.0.2:8080 -config-file=dbs.toml -instance=Moscow &
./dkv -db-location=moscow-r.db -http-addr=127.0.0.22:8080 -config-file=dbs.toml -instance=Moscow -replica &
./dkv -db-location=minsk.db -http-addr=127.0.0.3:8080 -config-file=dbs.toml -instance=Minsk &
./dkv -db-location=minsk-r.db -http-addr=127.0.0.33:8080 -config-file=dbs.toml -instance=Minsk -replica &
./dkv -db-location=kiev.db -http-addr=127.0.0.4:8080 -config-file=dbs.toml -instance=Kiev &
./dkv -db-location=kiev-r.db -http-addr=127.0.0.44:8080 -config-file=dbs.toml -instance=Kiev -replica &
./dkv -db-location=tashkent.db -http-addr=127.0.0.5:8080 -config-file=dbs.toml -instance=Tashkent &
./dkv -db-location=tashkent-r.db -http-addr=127.0.0.55:8080 -config-file=dbs.toml -instance=Tashkent -replica &

wait
